package io.renren.modules.gengyun.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.gengyun.dao.AirConditionHourlyDao;
import io.renren.modules.gengyun.entity.AirConditionHourlyEntity;
import io.renren.modules.gengyun.service.AirConditionHourlyService;


@Service("airConditionHourlyService")
public class AirConditionHourlyServiceImpl extends ServiceImpl<AirConditionHourlyDao, AirConditionHourlyEntity> implements AirConditionHourlyService {

    @Autowired
    AirConditionHourlyDao airConditionHourlyDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AirConditionHourlyEntity> page = this.page(
                new Query<AirConditionHourlyEntity>().getPage(params),
                new QueryWrapper<AirConditionHourlyEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 湿度
     * @param cropsRotationPlotId
     * @param beginTime
     * @param endTime
     * @return
     */
    @Override
    public List<Integer> getHumidityByCropRotationId(String cropsRotationPlotId, Long beginTime, Long endTime) {
        return airConditionHourlyDao.getHumidityByCropRotationId(cropsRotationPlotId, beginTime, endTime);
    }

    /**
     * 降雨量
     * @param cropsRotationPlotId
     * @param beginTime
     * @param endTime
     * @return
     */
    @Override
    public List<Integer> getPrecipitationByCropRotationId(String cropsRotationPlotId, Long beginTime, Long endTime) {
        return airConditionHourlyDao.getPrecipitationByCropRotationId(cropsRotationPlotId, beginTime, endTime);
    }

    /**
     * 湿度
     * @param cropsRotationPlotId
     * @param beginTime
     * @param endTime
     * @return
     */
    @Override
    public List<Integer> getTemperatureByCropRotationId(String cropsRotationPlotId, Long beginTime, Long endTime) {
        return airConditionHourlyDao.getTemperatureByCropRotationId(cropsRotationPlotId, beginTime, endTime);
    }

    @Override
    public List<Map> getAirLOT(String cropsRotationPlotId, String beginTime, String endTime) {
        return airConditionHourlyDao.getAirLOT(cropsRotationPlotId,beginTime,endTime);
    }
}
